package net.inxweb.bluemeerkat.web.support;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 

public class SearchMapListRequest<E extends Serializable> {
	private List<E> entitys = Collections.emptyList();
	
	private Map<String, Object> serachCondition = Collections.emptyMap();
	
	public Map<String, Object> getSerachCondition() {
		return serachCondition;
	}

	public SearchMapListRequest<E> addSerachCondition(String key, Object value) {
		if(serachCondition.isEmpty()) {
			serachCondition = new HashMap<String, Object>(); 
		}
		this.serachCondition.put(key, value);
		
		return this;
	}

	private Pagination pagination;

 
	public Pagination getPagination() {
		return pagination;
	}

	public SearchMapListRequest<E> setCurrentPageIndex(long currentPageIndex) {
		this.pagination = new Pagination(currentPageIndex);
		return this;
	}
 

	public List<E> getEntitys() {
		return entitys;
	}

	public void setList(List<E> entitys) {
		if(entitys.isEmpty()) {
			entitys = new ArrayList<E>(); 
		}
		this.entitys = entitys; 
	}

	public static class Pagination {
		public long pagePerRow;  
		public long currentPageIndex;	
		public long totalRowCount;
		
		public Pagination(long currentPageIndex) {
			this.currentPageIndex = currentPageIndex;
		}
	}
}